<?php

/**
 * Serverboy Cloud
 * http://cloud.serverboy.net/
 *
 * PHP version 5
 *
 * Copyright 2009 Matt Basta
 * 
 * @author     Matt Basta <matt@serverboy.net>
 * @link       http://serverboy.net/
*/


$location = dirname(__FILE__);
define('CLOUD_PATH_PREFIX', $location . (strlen($location) > 1 ? '/' : ''));

// Internal security can be super-secure, but possibly slow.
define('CLOUD_INTERNAL_SECURITY', true);

// Error handling
define('CLOUD_LOG', CLOUD_PATH_PREFIX . '../log.txt');
define('CLOUD_ALERT_UNSAFE_QUERIES', false);
define('CLOUD_ALERT_WARNINGS', false);
define('CLOUD_ALERT_ERRORS', true);
define('CLOUD_BREAK_ON_UNSAFE_QUERIES', false);
define('CLOUD_BREAK_ON_WARNINGS', false);
define('CLOUD_BREAK_ON_ERRORS', true);

// Base class
require(CLOUD_PATH_PREFIX . 'libraries/base.php');
require(CLOUD_PATH_PREFIX . 'libraries/logging.php');
require(CLOUD_PATH_PREFIX . 'libraries/simpleObjects.php');
// Credentials object
require(CLOUD_PATH_PREFIX . 'libraries/credentials.php');
// Universal DB Driver Interface
require(CLOUD_PATH_PREFIX . 'libraries/driver.php');
require(CLOUD_PATH_PREFIX . 'libraries/driver.table.php');
// Token class and helpers
require(CLOUD_PATH_PREFIX . 'libraries/token.php');


class cloud {
	
	public static function create_db($type, $credentials) {
		
		$db_path = CLOUD_PATH_PREFIX . 'engines/' . $type . '.driver.php';
		require_once($db_path);
		
		$db_class = $type . '_driver';
		
		$db = new $db_class($credentials);
		
		return $db;
		
	}
	
	public static function _comp($x, $comparison, $y) {
		$term_comparison = new comparison($x, $comparison, $y);
		return $term_comparison;
	}
	public static function _and($values) {
		$or_combinator = new logicCombinator($values, 'AND');
		return $or_combinator;
	}
	public static function _or($values) {
		$or_combinator = new logicCombinator($values, 'OR');
		return $or_combinator;
	}
	
}

